package design.patterns.structural.composite;

import java.util.HashSet;
import java.util.Set;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/4/4 17:26
 */
public class TreeNode {
    private String name;
    private TreeNode parentNode;
    private Set<TreeNode> childNodeSet = new HashSet<>();

    public TreeNode(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public TreeNode getParentNode() {
        return parentNode;
    }

    public String getParentName(){
        String result = null;
        if(parentNode != null){
            result = parentNode.getName();
        }
        return result;
    }

    public void addChildNode(TreeNode t){
        childNodeSet.add(t);
    }

    public void deleteChilNode(TreeNode t){
        childNodeSet.remove(t);
    }
}
